package com.lcf.app.shiro.service;

import com.lcf.app.shiro.common.model.User;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author ChenFei
 * @date 2021/11/2
 */
@Service
public class UserService {

    private static final String userId = "123456789";//测试用

    public User getByName(String name) {
        return "admin".equals(name) ? new User()
                .setId(userId)
                .setNickname("ChenFei")
                .setUsername("admin")
                .setSalt("4ol2tb2gqfbzw2l4ol40x8y9htqu6z6v")//随机生成的盐
                .setPassword("a4cf227a4fcde78d15d31dc87bbd9b6b") : null;//加密后的密码
    }

    public Set<String> getRoles() {
        return new HashSet<>(Arrays.asList("user"));
    }

    public Set<String> getPerms() {
        return new HashSet<>(Arrays.asList("user:read", "user:update"));
    }
}
